<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Category;
use backend\assets\AppAsset;

/* @var $this yii\web\View */
/* @var $model common\models\Category */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="category-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'pinyin_name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'parent_id')->dropDownList(Category::listid()) ?>

    <?= $form->field($model, 'img')->textInput(['maxlength' => true,'style'=>'width:60%;display: inline; 
    margin:0 20px 10px;']) ?>

    <?= $form->field($model, 'des')->textarea(['style' => 'width:760px;height:300px;']) ?>

    <?= $form->field($model, 'level')->textInput() ?>

    <?= $form->field($model, 'sort_number')->textInput() ?>

    <?= $form->field($model, 'is_show')->dropDownList(Category::itemAlias('is_show')) ?>

    <?php // $form->field($model, 'create_time')->textInput() ?>

    <?php // $form->field($model, 'update_time')->textInput() ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
<?php
$this->registerCssFile('/css/umeditor/themes/default/css/umeditor.css');

$this->registerJsFile('/css/umeditor/umeditor.config.js',[AppAsset::className(), 'depends' => 'backend\assets\AppAsset']);
$this->registerJsFile('/css/umeditor/umeditor.min.js',[AppAsset::className(), 'depends' => 'backend\assets\AppAsset']);
$this->registerJsFile('/css/umeditor/lang/zh-cn/zh-cn.js',[AppAsset::className(), 'depends' => 'backend\assets\AppAsset']);
?>

<?php $this->beginBlock('footer_js') ?>
//
jQuery(document).ready(function () {
    var button = '<button type="button" data-toggle="modal" data-target="#myModal" id="upload_img_url" upload_field="category-img"  style="">上传</button>';
    $('#category-img').after(button);
    $('#upload_img_url').click(function(){
        var upload_field = $(this).attr('upload_field');
        $('#upload_img_iframe').attr('src','/tool/uploadupyun?upload_field='+upload_field);
    });
});

jQuery(document).ready(function () {

    var um = UM.getEditor('category-des',{
        imageUrl:"/tool/umfile",
        imagePath:''
    });
});
<?php $this->endBlock() ?>  
<?php $this->registerJs($this->blocks['footer_js'], \yii\web\View::POS_END); ?>
